package com.briup.recognition.web.controller;

import com.briup.recognition.bean.BaseFile;
import com.briup.recognition.service.IBaseFileService;
import com.briup.recognition.utils.Message;
import com.briup.recognition.utils.MessageUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("basefile")
public class BaseFileController {

    @Resource
    private IBaseFileService baseFileService;

    @GetMapping("query")
    public Message query(){
        List<BaseFile> list = baseFileService.query();

        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseFile baseFile){
        baseFileService.saveOrUpdate(baseFile);
        System.out.println(baseFile.toString());
        return MessageUtil.success("更新成功");
    }

    @PostMapping("deleteById")
    public Message deleteBYId(String id){
        baseFileService.deleteById(id);

        return  MessageUtil.success("删除成功");
    }

}
